package com.hqu.ms.detail;

import android.support.v4.app.FragmentManager;
import android.support.v4.view.ViewPager;
import android.util.Log;

import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.googlecode.androidannotations.annotations.AfterViews;
import com.googlecode.androidannotations.annotations.EActivity;
import com.googlecode.androidannotations.annotations.Extra;
import com.googlecode.androidannotations.annotations.ViewById;
import com.hqu.ms.R;
import com.hqu.ms.entities.StoreEntivity;


@EActivity(R.layout.ms_detail_layout)
public class DetailActivity extends SherlockFragmentActivity{
	private final static String TAG = "DetailActivity";
	@ViewById
	ViewPager mPager;
	private DetailPageAdapter pageAdapter ;
	
	private FragmentManager fm;
	
	@Extra 
	StoreEntivity store;
	
	@AfterViews
	void afterViewInjected(){
		initData();
		
		Log.d(TAG, store.toString());
	}
	
	void initData(){
		fm = getSupportFragmentManager();
		pageAdapter = new DetailPageAdapter(fm, 3, store);
		mPager.setAdapter(pageAdapter);
	}
	
	public void setIndexSelected(int index){
		mPager.setCurrentItem(index);
	}
	
	@Override
	public void onBackPressed() {
		super.onBackPressed();
		finish();
		overridePendingTransition(
				R.anim.base_slide_left_in,
				R.anim.base_slide_right_out);
	}
}
